package icu.zhhll.filter;

import icu.zhhll.wrapper.BodyReaderHttpServletRequestWrapper;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @author zh
 * @date 2023/8/15 11:14
 */
public class ReadFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        BodyReaderHttpServletRequestWrapper wrapper = new BodyReaderHttpServletRequestWrapper((HttpServletRequest) request);
        wrapper.getInputStream();
        wrapper.getReader();
        chain.doFilter(wrapper, response);
    }

    @Override
    public void destroy() {

    }
}
